According to video compression standards for encoding/decoding video data, a frame is divided into a plurality of macro blocks and a macro block may be divided into a plurality of sub-blocks. The encoding/decoding is performed on the basis of a macro block unit or a sub-block unit based on temporal prediction and spatial prediction.
Herein, the temporal prediction is to predict motion of macro blocks or sub-blocks of a current frame by referring to blocks of adjacent frames.
The spatial prediction is to predict motion of macro blocks or sub-blocks of a current frame to be encoded by using boundary pixels of already recovered adjacent blocks.
The spatial prediction is also called intra prediction. The intra prediction takes advantage of a characteristic that when a pixel is predicted, pixels adjacent to it are highly likely to have similar values.
H.264/Advanced Video Coding (AVC) standard technology can compress video about twice as high as Moving Picture Experts Group 2 (MPEG-2) and about one and a half times as high as MPEG-4 by using such technique as intra prediction encoding, ¼-pixel based variable block motion prediction and compensation, Context-based Adaptive Variable Length Coding (CAVLC), and Context-based Adaptive Binary Arithmetic Coding (CABAC).
The H.264/AVC standard predicts pixel values of a current block by using prediction modes of 9 directivities.
FIG. 1 illustrates 9 prediction modes used for intra prediction of 4×4 blocks.
As illustrated in FIG. 1, the 9 prediction modes used for intra prediction of 4×4 blocks include a vertical mode (mode 0), a horizontal mode (mode 1), a direct current (DC) mode (mode 2), a diagonal_down_left mode (mode 3), a diagonal_down_right mode (mode 4), a vertical_right mode (mode 5), a horizontal_down mode (mode 6), a vertical_left mode (mode 7), and a horizontal_up mode (mode 8).
Herein, in the DC mode (mode 2), intra prediction is performed using a mean value of adjacent pixels. The arrows indicate prediction directions.
Meanwhile, intra 16×16 prediction encoding includes a total of four modes, which are a vertical mode, a horizontal mode, a DC mode, and a plane mode.
Also, intra 8×8 prediction encoding includes a total of 9 modes, just like the intra 4×4 prediction encoding. As for color difference signals, intra 8×8 prediction encoding is performed, and the intra 8×8 prediction encoding includes a DC mode, a vertical mode, a horizontal mode, and a plane mode and so on.
Hereinafter, prediction methods in the vertical and horizontal modes for intra prediction of 4×4 blocks will be described with reference to FIGS. 2 and 3.
FIG. 2 exemplarily illustrates a pixel prediction method in a vertical direction in a 4×4 block 200.
As shown in FIG. 2, pixel a 201, pixel e 202, pixel i 203, and pixel m 204 are predicted based on an adjacent pixel A in the vertical direction.
Also, pixels b, f, j and b are predicted based on an adjacent pixel B in the vertical direction, and pixels c, g, k and o are predicted based on an adjacent pixel C in the vertical direction. Pixels d, h, l and p are predicted based on an adjacent pixel D in the vertical direction.
FIG. 3 exemplarily illustrates a pixel prediction method in a horizontal direction in a 4×4 block 200.
As illustrated in FIG. 3, pixel a 205, pixel b 206, pixel c 207, and pixel d 208 are predicted based on an adjacent pixel l in a horizontal direction.
Also, pixels e, f, g and h are predicted based on an adjacent pixel J in the horizontal direction, and pixels i, j, k and l are predicted based on an adjacent pixel K in the horizontal direction. Pixels m, n, o and p are predicted based on an adjacent pixel L in the horizontal direction.
An encoder performs Discrete Cosine Transform (DCT) and quantization onto residual signals (which are of a pixel area) acquired by calculating differences between the predicted pixels and the current pixels. Subsequently, the encoder performs zigzag scanning and entropy encoding onto the transformed coefficients obtained from DCT and quantization.
Herein, although the zigzag scanning takes advantage of an energy compaction characteristic of a transformed coefficient that energy converges into low frequency components and energy appears little in high frequency components, the energy compaction after intra prediction is not always effective.
In short, the zigzag scanning is a method of scanning a transformed coefficient from low frequency components to high frequency components. When distribution of transformed coefficients appears more in the low frequency components, the zigzag scanning is effective. However, when spatial prediction having directivity is used, the distribution of transformed coefficients is influenced by the direction of prediction. Therefore, it is ineffective to apply the zigzag scanning to the prediction of all directions.